//
//  APITargetType.swift
//  
//
//  Created by tank on 2021/10/18.
//

import Foundation
import Moya
import LibBase

public protocol APITargetType: TargetType {
    var customizeHeaders: [String: String]? { get }
}

extension APITargetType {
    public var baseURL: URL {
        guard let baseUrl = HttpService.shared.apiBaseUrl else {
            fatalError()
        }

        return URL(string: baseUrl)!
    }
    
    public var customizeHeaders: [String: String]? {
        return nil
    }
    
    public var headers: [String: String]? {
        return Dictionary.merging(value1: HttpService.shared.headers(url: baseURL),
                                  value2: customizeHeaders)
    }
}
